#ifndef BACKPACK_INVENTORY_H_
#define BACKPACK_INVENTORY_H_

#include "Item.hpp"

#include <set>
#include <cassert>
#include <algorithm>

namespace backpack {



class Inventory {
public:
  bool containsItem(ItemVariant const& item) const {
    return (m_setItems.find(item) != m_setItems.end());
  }
  void addItem(ItemVariant const& item) {
    assert (m_setItems.find(item) == m_setItems.end());
    m_setItems.insert(item);
  }
  void removeItem(ItemVariant const& item) {
    assert (m_setItems.find(item) != m_setItems.end());
    m_setItems.erase(item);
  }

  template <class ItemVisitor>
  void acceptItemVisitor(ItemVisitor const& visitor) {
    std::for_each(
      m_setItems.begin(),
      m_setItems.end(),
      boost::apply_visitor(visitor)
      );
  }
private:
  std::set<ItemVariant> m_setItems;
}; // class Inventory



} // namespace backpack

#endif // BACKPACK_INVENTORY_H_
